<?php if(!defined('HDPHP_PATH'))exit;C('SHOW_NOTICE',FALSE);?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
    <title>分类管理</title>
    <link rel="stylesheet" type="text/css" href="http://localhost/e-shop/xiangqu/Static/hdjs/hdjs.css"/>
    <script src="http://localhost/e-shop/xiangqu/Static/js/jquery-1.7.2.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="http://localhost/e-shop/xiangqu/Static/hdjs/hdjs.min.js" type="text/javascript" charset="utf-8"></script>
    <link rel="stylesheet" type="text/css" href="http://localhost/e-shop/xiangqu/Static/bootstrap/bootstrap.min.css"/>
    <style type="text/css">
        .plus_minus{
            width: 20px;
        }
        .wrap .hd-btn{
        	margin: 0px;
        }
        a:hover{
        	text-decoration: none;
        }
        .glyphicon{
        	font:700 22px/25px "微软雅黑";
        }
    </style>
	<script type="text/javascript">
		$(function(){
			//隐藏非父级元素
			$('tr[pid!=0]').hide();
			//toggle事件
			$('.click-btn').toggle(function(){
				$(this).removeClass('glyphicon-plus').addClass('glyphicon-minus');
				var cid = $(this).parents('tr').attr('cid');
				$('tr[pid='+cid+']').show(200);
			},function(){
				//收
				$(this).removeClass('glyphicon-minus').addClass('glyphicon-plus');
				var cid = $(this).parents('tr').attr('cid');
				$.ajax({
					type:'post',
					url:"<?php echo U('Admin/Category/ajaxSoncid');?>",
					data:{cid:cid},
					dataType:'Json',
					success:function(phpData){
						//遍历对象，隐藏属于点击下的tr子分类
						$.each(phpData, function(k,v) {   
							$('tr[cid='+v+']').hide(200);                                                          
						});
					}
					
				})
				
			})
			
		})
	</script>
</head>
<body>
<div class="wrap">
    <table class="table2 hd-table hd-table-list">
        <thead>
        <tr pid=0>
            <td width="30"></td>
            <td>分类id</td>
            <td>分类名称</td>
            <td>分类排序</td>
            <td width="200">操作</td>
        </tr>
        </thead>
        <tbody>
        	<?php foreach ($data as $K=>$v){?>
        	<tr pid=<?php echo $v['pid'];?> cid=<?php echo $v['cid'];?>>
	            <td width="30">
	            	<a href="javascript:;" class="glyphicon glyphicon-plus click-btn"></a>
	            </td>
	            <td><?php echo $v['cid'];?></td>
	            <td><?php echo $v['_name'];?></td>
	            <td><?php echo $v['csort'];?></td>
	            <td width="200">
	            	<a href="<?php echo U('Admin/Category/addSon',array('cid'=>$v['cid']));?>" class="hd-btn hd-btn-success hd-btn-sm">添加子分类</a>
	            	<a href="<?php echo U('Admin/Category/edit',array('cid'=>$v['cid']));?>" class="hd-btn hd-btn-primary hd-btn-sm">编辑</a>
	            	<a href="javascript:hd_modal_del(<?php echo $v['cid'];?>)" class="hd-btn hd-btn-danger hd-btn-sm">删除</a>
	            </td>
            </tr>
            <?php }?>
        </tbody>
    </table>
    <div class="page_hdjob">
        
    </div>
</div>
<script type="text/javascript">
	function hd_modal_del(id) {
        hd_modal({
            width: 400,//宽度
            height: 150,//高度
            title: '确认删除吗？',//标题
            content: '',//提示信息
            button: true,//显示按钮
            button_success: "确定",//确定按钮文字
            button_cancel: "取消",//关闭按钮文字
            timeout: 0,//自动关闭时间 0：不自动关闭
            shade: true,//背景遮罩
            shadeOpacity: 0.4,//背景透明度
            success: function () {//点击确定后的事件
				location.href = "http://localhost/e-shop/xiangqu/index.php/Admin/Category" + '/delete/cid/' + id;
            },
            cancel: function () {//点击关闭后的事件
				
            }
        });
    }
</script>
</body>
</html>


